var crypto = require('crypto')
var CryptoJS = require("crypto-js");
/**
 * 解密后端加密文本
 *
 * @param {string} str 待解密字符串
 * @returns
 */
export const decrypt = (str) => {
    let saltKey = "2ac4e2b67dd4c828";
    let vectorKey = "2ac4e2b67dd4c828";
    let keyBase64 = CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(saltKey))
    let ivBase64 = CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(vectorKey))
    let key = Buffer.from(keyBase64, 'base64');
    let iv  = Buffer.from(ivBase64, 'base64');
    let decipher = crypto.createDecipheriv('aes-128-cbc', key, iv.slice(0, 16));
    let decrypted  = decipher.update(str, 'base64');
    return Buffer.concat([decrypted, decipher.final()]).toString()
 }